<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 语法糖
        // 尽可能的简化沙箱的语法 
        // 利用 get set 

        function outer(){
            let num1 = 100;
            let num2 = 200;
            const obj = {
                get num1(){
                    return num1;
                },
                get num2(){
                    return num2;
                },
                set num1(val){
                    num1 = val;
                },
                set num2(val){
                    num2 = val;
                }
            }
            return obj;
        }

        const obj1 = outer();
        console.log(obj1.num1);
        console.log(obj1.num2);
        obj1.num1 = 1000;
        obj1.num2 = 2000;
        console.log(obj1.num1);
        console.log(obj1.num2);

        const obj2 = outer();
        console.log(obj2.num1);
        console.log(obj2.num2);
    </script>
</body>
</html>